//
//  GYAddNotDisturbViewController.m
//  Visitor
//
//  Created by x on 2017/9/20.
//  Copyright © 2017年 HLB. All rights reserved.
//

#import "GYAddNotDisturbViewController.h"
#import "GYDetailsTableViewCell.h"
#import "GYNotDisturbCell.h"
#import "GYNotDisturbReasonCell.h"

@interface GYAddNotDisturbViewController ()<UITableViewDelegate,UITableViewDataSource>

/** 表格 */
@property (weak, nonatomic) IBOutlet UITableView *tableView;

/** 标题数组 */
@property (nonatomic, strong) NSArray *titles;
@end

@implementation GYAddNotDisturbViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupUI];
}

- (void)setupUI {
    self.title = @"免打扰方式";
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.sectionHeaderHeight = 10;
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtoonClick)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtoonClick)];
}

- (void)leftBarButtoonClick {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)rightBarButtoonClick {

}

#pragma mark -- <UITableViewDelegate,UITableViewDataSource>

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titles.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        GYDetailsTableViewCell *cell = [GYDetailsTableViewCell cellWithTableView:tableView];
        cell.title = self.titles[indexPath.row];
        cell.content = @"午休";
        
        return cell;
    }else {
        GYNotDisturbReasonCell *cell = [GYNotDisturbReasonCell cellWithTableView:tableView];
        cell.title = self.titles[indexPath.row];
        
        return cell;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 10)];
    view.backgroundColor = [UIColor clearColor];
    
    return view;
}


#pragma  mark -- 懒加载

- (NSArray *)titles
{
    if (!_titles) {
        _titles = @[@"事由",@"开始时间",@"结束时间"];
    }
    return _titles;
}

@end
